#ifndef __MPP_SHOWING_H__
#define __MPP_SHOWING_H__
#include "mpp_screens.h"
#include "mpp_display_buffer.h"
#include "drmrga.h"    // --需要用到RK 提供的RGA模块来进行拼接，裁剪，缩放和转换FD等功能


class mpp_showing 
{
    public:

        mpp_showing(mpp_screens *screens);
        bool is_showing();
        int mpp_show_background(string path);
        int mpp_show_yuv(int fd,uint32_t width,uint32_t height,void *date);
        int mpp_show_rgba(int fd,uint32_t width,uint32_t height,void *date);
        
        ~mpp_showing();
    private:
        typedef int(* FUNC_RGA_INIT)();
        typedef void(* FUNC_RGA_DEINIT)();

        typedef int (*FUNC_GetAllocBuffer)(bo_t *bo_info, int width, int height, int bpp);    //--申请空间
        typedef  int (*FUNC_GetMmap)(bo_t *bo_info);                                                         //--映射空间
        typedef  int (*FUNC_GetBufferFd)(bo_t *bo_info, int *fd);                                          //--拿到文件描述符供DRM用
        typedef  int (*FUNC_Unmap)(bo_t *bo_info);                                                              //--反映射空间
        typedef  int (*FUNC_Free)(bo_t *bo_info);                                                                   //--释放空间

        typedef int(* FUNC_RGA_BLIT)(rga_info_t *, rga_info_t *, rga_info_t *);                       //--裁剪，格式转换，缩放，拼接等操作
        typedef struct _rga_context{
            void *rga_handle;
            FUNC_RGA_INIT init_func;
            FUNC_RGA_DEINIT deinit_func;

            FUNC_GetAllocBuffer alloc_buffer;
            FUNC_GetMmap          get_mmap;
            FUNC_GetBufferFd        get_bufferFd;
            FUNC_Unmap                unmap;
            FUNC_Free                     free_buffer;

            FUNC_RGA_BLIT               blit_func;
        } rga_context;

        typedef struct 
        {
            uint32_t fb_id;
            uint32_t t_handle;
        }buffer_obj;
        buffer_obj *m_buffer_obj;



        void mpp_drow_background(string path);

        int rga_control_buffer_init(bo_t *bo, int *buf_fd, int width, int height, int bpp);
        void rga_control_buffer_deinit(bo_t *bo, int buf_fd);

         mpp_screens *m_screens;
         mpp_display_buffer *m_buffer;
         rga_context        *m_rga_ctx;

        uint8_t *background_src;


        bo_t rga_bo;    //--RGA对象
        int    rga_fd;    //--RGA文件描述符
         

};


#endif